using System;
using System.Collections;
using System.Collections.Generic;
using ttbit.form;
using ttbit.form.unity;
using UnityEngine;
using UnityEngine.UI;

public class comp_env : MonoBehaviour, ttbit.form.IEnv
{
    public Camera mainCamera;
    public IPlatform Platform
    {
        get;
        private set;
    }
    ttbit.form.unity.Graphic realgraph;
    public IGraphic Graphic => realgraph;


    public IInput Input
    {
        get;
        private set;
    }

    ttbit.form.unity.FileIO realfileio;
    public IFileIO FileIO => realfileio;


    public IAudio Audio
    {
        get;
        private set;
    }

    // Start is called before the first frame update
    void Awake()
    {
        if (mainCamera == null)
        {
            mainCamera = Camera.main;
        }
        Platform = new Platform();
        GameObject roottran = new GameObject("ttbit.root");
        realgraph = new ttbit.form.unity.Graphic(mainCamera, roottran.transform);
        Input = new ttbit.form.unity.Input();
        realfileio = new FileIO();
        Audio = new Audio();



        Env.Init(this);

    }
    void OnPreRender()
    {

    }

    // Update is called once per frame
    void Update()
    {

        realgraph.OneFrame();
    }

    public void Log(string message, LogLevel level = LogLevel.Normal)
    {
        if (level == LogLevel.Normal)
        {
            Debug.Log(message);
        }
        else if (level == LogLevel.Warning)
        {
            Debug.LogWarning(message);
        }
        else
        {
            Debug.LogError(message);
        }
    }
}
